package com.gyms.manager;


import com.classic.okhttp.Cons;
import com.classic.okhttp.beans.HVShareActivityBean;
import com.classic.okhttp.beans.HVUserBaseInfoBean;
import com.gyms.bean.LocationBean;
import com.orhanobut.logger.Logger;

import utils.StringUtils;

/**
 * 数据中心
 */
public class DataCenter {
    private static DataCenter instance = null;
    private String aesKey = null;
    /*private String Token = Cons.mToken;*/
    private String Token = "";//方便调试，暂时写死
    private HVUserBaseInfoBean user = null;//用户信息
    private int messageCount = 0; //消息数
    private int cardsCount = 0; //卡券数
    private int collectionCount = 0; //收藏数

    private String cityCode="330100";//城市代号
    private double longitude=104.04701001273;//经度
    private double latitude=30.548396923974;//纬度
    private String city="杭州市";//定位城市
//    private Address address;

    //定位的Bean
    private LocationBean mLocationBean;

    public boolean isFirst;//是否是第一次打开app

    private HVShareActivityBean mHVShareActivityBean;//活动相关


    private DataCenter() {
        instance = this;
    }

    public static void initDataCenter() {
        if (null == instance)
            new DataCenter();
    }

    public static DataCenter getInstance() {
        return instance;
    }

    public String getToken() {
        return Token;
    }

    public void setToken(String token) {
        Cons.mToken = token;
        Token = token;
    }



    public HVUserBaseInfoBean getUser() {
        return user;
    }

    public String getUserId(){
        return StringUtils.isNull(user)?null:user.userid;
    }

    public void setUser(HVUserBaseInfoBean user) {
        this.user = user;
    }

    public int getMessageCount() {
        return messageCount;
    }

    public void setMessageCount(int messageCount) {
        this.messageCount = messageCount;
    }

    public int getCardsCount() {
        return cardsCount;
    }

    public void setCardsCount(int cardsCount) {
        this.cardsCount = cardsCount;
    }

    public int getCollectionCount() {
        return collectionCount;
    }

    public void setCollectionCount(int collectionCount) {
        this.collectionCount = collectionCount;
    }

    public double getLongitude() {
        return !StringUtils.isNull(mLocationBean)?mLocationBean.getLongitude():longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return !StringUtils.isNull(mLocationBean)?mLocationBean.getLatitude():latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public String getCity() {
        return !StringUtils.isNull(mLocationBean)?mLocationBean.getCity():city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getAesKey() {
        return aesKey;
    }

    public void setAesKey(String aesKey) {
        this.aesKey = aesKey;
    }

    /**
     * 根据token判断是否已经登录
     *
     * @return
     */
    public boolean checkIsLogin() {
        boolean isLogin = StringUtils.isEmpty(getToken()) ? false : true;
        Logger.e("toaken="+Token);
        return isLogin;
    }

    public LocationBean getLocationBean() {
        return mLocationBean;
    }

    public void setLocationBean(LocationBean locationBean) {
        mLocationBean = locationBean;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    //获取活动类

    public HVShareActivityBean getHVShareActivityBean() {
        return mHVShareActivityBean;
    }

    public void setHVShareActivityBean(HVShareActivityBean HVShareActivityBean) {
        mHVShareActivityBean = HVShareActivityBean;
    }
}
